package com.example.zhibo.common;

import org.bytedeco.javacv.FrameGrabber;
import org.bytedeco.javacv.VideoInputFrameGrabber;

import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.Mixer.Info;

public class HardwareInfo {
    public static void main(String[] args) throws FrameGrabber.Exception {
        Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();
        String[] deviceDescriptions = VideoInputFrameGrabber.getDeviceDescriptions();

        // 获取第一个音频输入设备信息
        if (mixerInfos.length > 1) {
            Info secondAudioInputInfo = mixerInfos[1];
            String secondAudioInputName = secondAudioInputInfo.getName().replace("Port ", "");
            System.out.println("第二个音频输入设备名称: " + secondAudioInputName);
            System.out.println("第二个音频输入设备描述: " + secondAudioInputInfo.getDescription());
            System.out.println("第二个音频输入设备供应商: " + secondAudioInputInfo.getVendor());
            System.out.println("第二个音频输入设备版本号: " + secondAudioInputInfo.getVersion());
            System.out.println();
        }

        // 获取视频输入设备信息
        if (deviceDescriptions != null && deviceDescriptions.length > 0) {
            String videoInputDeviceName = deviceDescriptions[0];
            System.out.println("视频输入设备名称: " + videoInputDeviceName);
        }
    }
}
